package com.sfdcj.se.meta.field;

import java.util.HashMap;

import com.sforce.soap._2006._04.metadata.CustomField;

/*
 <fields>
 <fullName>Field5__c</fullName>
 <defaultValue>false</defaultValue>
 <label>�`�F�b�N�{�b�N�X</label>
 <type>Checkbox</type>
 </fields>
 */

public class CheckboxType extends FieldType {

	static final String TYPE = "Checkbox";

	public boolean defaultValue;

	public CheckboxType() {
		super();
	}

	public void appendXML() {
		buf.append("<defaultValue>" + defaultValue + "</defaultValue>");
		buf.append("<type>" + TYPE + "</type>");
	}

	@Override
	public String getTypeName() {
		return TYPE;
	}

	@Override
	public Object clone() {
		return new CheckboxType();
	}

	@Override
	public void setAttributes(HashMap<String, String> attributes) {
		defaultValue = Boolean.getBoolean(attributes.get("defaultValue"));
	}

	@Override
	public CustomField toCustomField() {
		CustomField field = new CustomField();
		field.setFullName(objectFullname + "." + fullname);
		field.setLabel(label);
		field.setDefaultValue("" + defaultValue);
		field.setType(com.sforce.soap._2006._04.metadata.FieldType.Checkbox);
		return field;
	}
}
